package com.xuelang.pipeline.client.task;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.task.dto.TaskDefDTO;
import com.xuelang.pipeline.client.task.dto.TaskDefQuery;
import com.xuelang.pipeline.client.task.dto.TaskTypeFormDTO;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 流水线任务定义服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface ITaskDefService {

    /**
     * 查询流水线任务定义列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<TaskDefDTO>> pageTaskDefList(@RequestBody @Valid PageParam<TaskDefQuery> dtoPageParam);

    /**
     * 查询流水线任务定义列表(有过滤条件)
     *
     * @param taskDefQuery
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<TaskDefDTO>> conditionalTaskDefList(@RequestBody @Valid TaskDefQuery taskDefQuery);

    /**
     * 查询流水线任务定义列表，包含任务数据
     *
     * @param taskDefQuery
     * @return
     */
    @PostMapping(value = "/assemblyList", produces = "application/json;charset=utf-8")
    ApiResult<List<TaskTypeFormDTO>> conditionalTaskDefAssemblyList(@RequestBody @Valid TaskDefQuery taskDefQuery);

    /**
     * 新增流水线任务定义
     *
     * @param taskDefDTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addTaskDef(@RequestBody @Valid TaskDefDTO taskDefDTO);

    /**
     * 更新流水线任务定义
     *
     * @param taskDefDTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateTaskDef(@RequestBody @Valid TaskDefDTO taskDefDTO);

    /**
     * 删除流水线任务定义
     *
     * @param uuid
     * @return
     */
    @DeleteMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteTaskDef(@PathVariable("uuid") String uuid);

    /**
     * 查询流水线任务定义
     *
     * @param uuid
     * @return
     */
    @GetMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<TaskDefDTO> queryTaskDef(@PathVariable("uuid") String uuid);
}
